﻿using System;
using System.Collections.Generic;
using System.IO;
using System.IO.MemoryMappedFiles;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RRSimulator.BlobManager.Lib.Model
{
    public class FileModel : ModelBase
    {
        private bool _isDisposed;

        public string FileName { get; set; }
        public string FilePath { get; set; }
        public string FileType { get; set; }
        public byte[] FileBytes { get; set; }
        public MemoryMappedFile MemoryMappedFile { get; set; }
        public string FileHash { get; set; }
        public int CurrentRetryTimes { get; set; }
        public bool IsProcessing { get; set; }

        ~FileModel()
        {
            Dispose(false);
        }

        protected override void Dispose(bool isDisposing)
        {
            if (_isDisposed)
                return;

            if (isDisposing)
            {
                FileName = null;
                FileBytes = null;
                MemoryMappedFile = null;
                FileHash = null;
            }

            _isDisposed = true;
        }
    }
}
